//
//  OtherShopDetailTableViewCell.m
//  GoShops
//
//  Created by zcj on 15-12-1.
//  Copyright (c) 2015年 郑朝军. All rights reserved.
//

#import "OtherShopDetailTableViewCell.h"
#import "Grouble.h"

@interface OtherShopDetailTableViewCell()
@property (nonatomic,weak) UIImageView * shopImageView;
@property (nonatomic,weak) UILabel *shopNameLabel;
@property (nonatomic,weak) UILabel *shopIntroduceLabel;
@property (nonatomic,weak) UILabel *priceLabel;
@property (nonatomic,weak) UILabel *yuanPriceLabel;
@end
@implementation OtherShopDetailTableViewCell

+(instancetype)OtherShopDetailTableViewCell:(UITableView *)tableView
{
    static NSString *menuID = @"OtherShopDetail";
    OtherShopDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:menuID];
    if (cell == nil) {
        cell = [[OtherShopDetailTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:menuID];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        UIView * backView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 120)];
        backView.backgroundColor = [UIColor clearColor];
        ZCJLog(@"%f",self.frame.size.height);
        [self addSubview:backView];
        CGFloat margn = 10;
        CGFloat shopImageW = 100;
        CGRect shopImg = CGRectMake(margn, margn, shopImageW, shopImageW);
        self.imageView.frame = shopImg;
        
        NSString * nameStr = @"小样";
        CGFloat nameX = CGRectGetMaxX(shopImg) + 2*margn;
        CGSize nameH = [nameStr sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20]}];
        CGFloat nameW = ScreenWidth - 80 - margn * 5;
        
        CGRect shopNameLabelRect = CGRectMake(nameX, margn, nameW, nameH.height);
        UILabel* shopNameLabel = [[UILabel alloc]initWithFrame:shopNameLabelRect];
        shopNameLabel.font = [UIFont systemFontOfSize:15];
        
        [backView addSubview:shopNameLabel];
        self.shopNameLabel = shopNameLabel;
        
        CGFloat sunX = nameX;
        CGFloat sunY = margn*2 + nameH.height;
        CGFloat sunW = nameW;
        CGFloat sunH = nameH.height;
        CGRect sunRect = CGRectMake(sunX, sunY, sunW, sunH);
        UILabel * shopIntroduceLabel = [[UILabel alloc]initWithFrame:sunRect];
        shopIntroduceLabel.font = [UIFont systemFontOfSize:10];
        
        [backView addSubview:shopIntroduceLabel];
        self.shopIntroduceLabel = shopIntroduceLabel;
        
        CGFloat priceX = sunX;
        CGFloat priceY = CGRectGetMaxY(sunRect) + margn;
        CGFloat priceW = sunW * 0.5;
        CGFloat priceH = sunH;
        CGRect priceRect = CGRectMake(priceX, priceY, priceW, priceH);
        
        UILabel * priceLabel = [[UILabel alloc]initWithFrame:priceRect];
        priceLabel.textColor = [UIColor blackColor];
        priceLabel.font = [UIFont systemFontOfSize:25];
        priceLabel.textAlignment = NSTextAlignmentCenter;
        
        [backView addSubview:priceLabel];
        self.priceLabel = priceLabel;
    
        
        
        CGFloat yuanX = CGRectGetMaxX(priceRect) + margn;
        CGFloat yuanY = priceY;
        UIView * yuanView = [[UIView alloc]initWithFrame:CGRectMake(yuanX, yuanY, priceW, priceH)];
        //yuanView.backgroundColor = [UIColor redColor];
        UIView * xian = [[UIView alloc]initWithFrame:CGRectMake(0, 13, 45, 1)];
        xian.backgroundColor = [UIColor blackColor];
        [yuanView addSubview:xian];
        
        UILabel * yuanLable = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, priceW, priceH)];
        yuanLable.text = @"2232";
        yuanLable.textColor = ZCJColor(68, 201, 186);
        yuanLable.font = [UIFont systemFontOfSize:15];
        yuanLable.textAlignment = NSTextAlignmentLeft;
        [yuanView addSubview:yuanLable];
        self.yuanPriceLabel = yuanLable;
        [self addSubview:yuanView];
    }
    return self;
}
- (void)setArrayGroup:(ArrayGroupModel *)arrayGroup
{
    _arrayGroup = arrayGroup;
    NSString *imgUrl = [arrayGroup.squareimgurl stringByReplacingOccurrencesOfString:@"w.h" withString:@"160.160"];
    
    [self.imageView setImageWithURL:[NSURL URLWithString:imgUrl] placeholderImage:[UIImage imageNamed:@"faxing"]];
    
    self.shopNameLabel.text = arrayGroup.mname;
    self.shopIntroduceLabel.text = [NSString stringWithFormat:@"[%@]%@",arrayGroup.range,arrayGroup.title];
    //
    NSString *str = [NSString stringWithFormat:@"%@元",arrayGroup.price];
  
    self.priceLabel.text = str;
    //
    NSString *strOld = [NSString stringWithFormat:@"%@元",arrayGroup.value];
    
    self.yuanPriceLabel.text = strOld;

    

}
- (void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat margn = 10;
    CGFloat shopImageW = 100;
    CGRect shopImg = CGRectMake(margn, margn, shopImageW, shopImageW);
    self.imageView.frame = shopImg;
    //ZCJLog(@"%f",self.frame.size.height);
}
- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
